package com.ruoyi.healthCard.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.healthCard.domain.TBizCertDistribution;
import com.ruoyi.healthCard.service.ITBizCertDistributionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 健康证发放Controller
 * 
 * @author ruoyi
 * @date 2025-06-27
 */
@RestController
@RequestMapping("/health/distribution")
public class TBizCertDistributionController extends BaseController
{
    @Autowired
    private ITBizCertDistributionService tBizCertDistributionService;

    /**
     * 查询健康证发放列表
     */
    @PreAuthorize("@ss.hasPermi('health:distribution:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBizCertDistribution tBizCertDistribution)
    {
        startPage();
        List<TBizCertDistribution> list = tBizCertDistributionService.selectTBizCertDistributionList(tBizCertDistribution);
        return getDataTable(list);
    }

    /**
     * 导出健康证发放列表
     */
    @PreAuthorize("@ss.hasPermi('health:distribution:export')")
    @Log(title = "健康证发放", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBizCertDistribution tBizCertDistribution)
    {
        List<TBizCertDistribution> list = tBizCertDistributionService.selectTBizCertDistributionList(tBizCertDistribution);
        ExcelUtil<TBizCertDistribution> util = new ExcelUtil<TBizCertDistribution>(TBizCertDistribution.class);
        util.exportExcel(response, list, "健康证发放数据");
    }

    /**
     * 获取健康证发放详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:distribution:query')")
    @GetMapping(value = "/{distId}")
    public AjaxResult getInfo(@PathVariable("distId") Long distId)
    {
        return success(tBizCertDistributionService.selectTBizCertDistributionByDistId(distId));
    }

    /**
     * 新增健康证发放
     */
    @PreAuthorize("@ss.hasPermi('health:distribution:add')")
    @Log(title = "健康证发放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBizCertDistribution tBizCertDistribution)
    {
        return toAjax(tBizCertDistributionService.insertTBizCertDistribution(tBizCertDistribution));
    }

    /**
     * 修改健康证发放
     */
    @PreAuthorize("@ss.hasPermi('health:distribution:edit')")
    @Log(title = "健康证发放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBizCertDistribution tBizCertDistribution)
    {
        return toAjax(tBizCertDistributionService.updateTBizCertDistribution(tBizCertDistribution));
    }

    /**
     * 删除健康证发放
     */
    @PreAuthorize("@ss.hasPermi('health:distribution:remove')")
    @Log(title = "健康证发放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{distIds}")
    public AjaxResult remove(@PathVariable Long[] distIds)
    {
        return toAjax(tBizCertDistributionService.deleteTBizCertDistributionByDistIds(distIds));
    }
}
